using System;
using System.Collections.Generic;
using NUnit.Framework;

namespace Salient.Data.Tests
{
    /// <summary>
    /// Quick sanity check
    /// </summary>
    [TestFixture]
    public class ListDataReaderSanityCheckFixture
    {
        [Test]
        public void Test()
        {
            var l = new List<DataObj>
                        {
                            new DataObj {Name = "1", Age = 16},
                            new DataObj {Name = "2", Age = 26},
                            new DataObj {Name = "3", Age = 36},
                            new DataObj {Name = "4", Age = 46}
                        };

            var r = new ListDataReader<DataObj>(l);
            while (r.Read())
            {
                var values = new object[2];
                int count = r.GetValues(values);
                Assert.AreEqual(2, count);

                values = new object[1];
                count = r.GetValues(values);
                Assert.AreEqual(1, count);

                values = new object[3];
                count = r.GetValues(values);
                Assert.AreEqual(2, count);

                Assert.IsInstanceOf(typeof (string), r.GetValue(0));
                Assert.IsInstanceOf(typeof (int), r.GetValue(1));

                Console.WriteLine("Name: {0}, Age: {1}", r.GetValue(0), r.GetValue(1));
            }
        }
    }
}